perm filename FROM.SAI[SAI,LES]1 blob
sn#834851 filedate 1987-02-19 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 begin "FROM"
C00004 00003 ! Execution
C00007 ENDMK
C⊗;
begin "FROM"
require "head" source_file;
!
Scans one or more message files containing at most one message per page,
extracts the return address from the "From:" line of each message,
separates the host name from the user ID, and outputs a text file
containing one line per input message in the form
<host> <user ID> <file number>
where <file number> is the integer number of files that have been read,
beginning with 1. The last line of the output file will be a list of the
files read:
<1st file name> <2nd file name> <3rd file name> <etc.>
1987 Feb. 19: First version written by Les Earnest for SU-bboards census.
;
break(inlineups,LF&FF,CR,"IKNS"); ! read a line upper-casified;
scnbrk(tolbroks,"<","","IS"); ! scan to "<";
scnbrk(torbroks,">","","IS"); ! scan to ">";
scnbrk(toats,"@","","IS"); ! scan to "@";
! Execution;
string filist;
integer fileno;
filist←"";
enton(ask("Finds where and who mail came from.
Output file="));
fileno←0;
while true do begin "main"
string ifile, aline;
integer pageno;
label ckpage;
boolean fl;
do begin "read"
release (inch);
if ln(ifile←ask("Message file=")) = 0 then begin "quit"
cprint(ouch,filist,↓);
exit
end;
open(inch←getchan,"DSK",1,19,0,400,brk,eof);
lookup(inch,ifile,fl);
end "read"
until ¬fl;
filist←filist&" "&ifile;
fileno←fileno + 1;
pageno←0;
ckpage:
while ¬eof do begin "file"
string host,id;
proc barf(string msg); ! grumble;
print("Page ",pageno,": ",msg,↓);
pageno←pageno + 1;
while ¬ equ((aline←input(inch,inlineups))[1 to 5],"FROM:") do
if brk=ff ∨ eof then begin
barf("No ""From:"" found");
goto ckpage
end;
host←tolbroks(aline);
if brk = "<" then host←torbroks(aline) else begin "nobroket"
aline←host[6 to ∞]; ! skip the "From:";
toprintr(aline);
host←towhites(aline);
end "nobroket";
! now we should have id@host;
id←toats(host);
if brk≠"@" then barf("No ""@"" found ")
else if ln(host)=0 then barf("No host")
else if ln(id)=0 then barf("No user id")
else cprint(ouch,host," ",id," ",fileno,↓);
do informs until brk=ff ∨ eof;
end "file";
end "main";
end